package com.cjd.view.radar

import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout

/**
 * @Author chenjidong
 * @email 374122600@qq.com
 * created 2019/9/23
 * description 雷达view 组合
 */
class RadarControlView @JvmOverloads constructor(
    context: Context,
    attributeSet: AttributeSet? = null,
    defStyleAttr: Int = 0
) : FrameLayout(context, attributeSet, defStyleAttr) {

    private val randomTextView: RadarMatrixTextView by lazy {
        RadarMatrixTextView(context)
    }

    private val radarScanView: RadarScanView by lazy {
        RadarScanView(context)
    }

    init {
        addView(randomTextView)
        addView(radarScanView)
    }

    private fun dp2px(dValue: Float): Int {
        return (context.resources.displayMetrics.density * dValue + 0.5F).toInt()
    }


    fun addKeyword(keyword: String) {
        randomTextView.addKeyword(keyword)
    }

    fun showText() {
        randomTextView.show()
    }

    fun getScanView() = radarScanView

    fun getTextView() = randomTextView

    fun setRippleColor(color: Int) {
        getTextView().rippleColor = color
        getTextView().show()
    }
}